def lengthOfLongestSubstring(s: str) -> int:
    i, j = 0, 0
    n = len(s)
    res = 0
    d = set()
    while j < n:
        if s[j] not in d:
            d.add(s[j])
            res = max(res, j - i + 1)
            j += 1
        else:
            d.remove(s[i])
            i += 1
    return res


print(lengthOfLongestSubstring("asdasdASdafadewqdeasdsdDdada"))

